<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateTableOrders extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('orders', function (Blueprint $table) {
            $table->increments('id')->comment('订单编号');
            $table->decimal('money',10,1)->unsigned()->default(0.0)->comment('订单金额');
            $table->decimal('total_money',10,1)->unsigned()->default(0.0)->comment('商品总额');
            $table->string('state',1)->default('1')->comment('订单状态');
            $table->string('pay_way',1)->default('1')->comment('支付方式');
            $table->text('content')->comment('订单留言');
            $table->string('order_time')->default('0')->comment('下单时间');
            $table->string('pay_time')->default('0')->comment('付款时间');
            $table->string('send_time')->default('0')->comment('发货时间');
            $table->string('logistics_name')->comment('物流名称');
            $table->string('awb_number')->comment('运单编号');
            $table->decimal('logistics_money')->unsigned()->default(0.0)->comment('物流运费');
            $table->string('user_id',1)->default('0')->comment('users表外键');
            $table->string('user_name')->default('')->comment('用户名');
            $table->string('real_name')->default('')->comment('收货人姓名');
            $table->string('phone')->default('')->comment('收货人手机');
            $table->string('address')->default('')->comment('用户地址');
            $table->timestamps();

            $table->foreign('user_id')->references('id')->on('users');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('orders');
    }
}
